home *** CD-ROM | disk | FTP | other *** search
- //machineEnvConstructor.cpp ©1996 Brian Bergstrand 07/16/96
-
- //headers
- #include "sysEnv.h"
- #include "systems.h"
-
- //constructor for Class MachineEnv
- MachineEnv::MachineEnv ()//define the constructor
- {
- OSErr myErr;
- long response, update, machine, proc, ram, logicalRam;
-
- /*If making a global variable of the class, uncomment the following
- error checking code, and substitute in the correct constants for your
- resource ID's.
- This is because global class variables get intialized
- even before main() is called. Otherwise, you can check for Gestalt in your
- own code.*/
- /*
- //test for gestalt, don't really need to do this, but Apple still recommends it
- myErr = Gestalt (gestaltVersion, &response);
- if (myErr)//if gestalt is not present
- {
- ExitToShell();//just exit
- }
- */
-
- myErr = Gestalt (gestaltSystemVersion, &response);//query for system version
- if (myErr == noErr)//if there was not an error
- {
- sysVer = response;//set the system version
- if (response>=_753)//if the system is 7.5.3 or greater, check for an update
- {
- myErr = Gestalt ('sysu', &update);
- if (myErr == noErr)//if there was not an error
- updateVer = update;//set the update version
- else//if there was a problem or no update is available
- updateVer = false;//make sure we give it a value, or we crash
- }
- }
- else//if there was a problem make sure we give it a value, or we crash
- sysVer = 0;
-
- //the rest of these follow the same format as above, so substitute comments in
- myErr = Gestalt (gestaltMachineType, &machine);
- if (myErr == noErr)
- machineType = machine;
- else
- machineType = 0;
-
- myErr = Gestalt (gestaltNativeCPUtype, &proc);
- if (myErr == noErr)
- processor = proc;
- else
- processor = 0;
-
- myErr = Gestalt (gestaltPhysicalRAMSize, &ram);
- if (myErr == noErr)
- realMem = ram;
- else
- realMem = 0;
-
- myErr = Gestalt (gestaltLogicalRAMSize, &logicalRam);
- if (myErr == noErr)
- logicalMem = logicalRam;
- else
- logicalMem = 0;
-
- myErr = Gestalt (gestaltVMAttr, &response);//check for VM
- if (myErr == noErr)
- {
- if (response == gestaltVMPresent)//is VM present
- VMon = true;
- else
- VMon = false;
- }
- else
- VMon = false;
- }